﻿<UserControl 
	x:Class="Pronama.NamaAlert.AddIn.AlertSidebarPage"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	d:DesignHeight="400" d:DesignWidth="250">

	<UserControl.Resources>
		<Style x:Key="RichTextBoxStyle" TargetType="RichTextBox">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="RichTextBox">
						<Grid x:Name="RootElement">
							<Grid x:Name="ContentElement" Background="White" />
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

        <Style x:Key="AlertItemContainerStyle" TargetType="ListBoxItem">
            <Setter Property="Margin" Value="0" />      
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid>
                            <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
		<DataTemplate x:Key="AlertItemTemplate">
			<Border BorderThickness="0,0,0,1" BorderBrush="LightGray" Margin="5 5 0 0" Padding="0 0 0 2" HorizontalAlignment="Stretch">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" />
						<ColumnDefinition />
					</Grid.ColumnDefinitions>
					<Image Width="64" Height="64" Margin="0" VerticalAlignment="Top" Source="{Binding IconUri}" />
					<Grid Grid.Column="1" Margin="5 0 0 0">
						<!--<Grid.RowDefinitions>
							<RowDefinition />
						</Grid.RowDefinitions>-->

						<RichTextBox IsReadOnly="True" Style="{StaticResource RichTextBoxStyle}">
							<Paragraph>
								<Hyperlink Command="{Binding OpenUriCommand}" CommandParameter="{Binding Uri}" TextDecorations="None" MouseOverTextDecorations="Underline">
									<Run Text="{Binding Title}" />
								</Hyperlink>
							</Paragraph>
							<Paragraph>
								<Run Text="{Binding Description}" />
							</Paragraph>
							<Paragraph>
                                <Hyperlink Command="{Binding OpenUriCommand}" CommandParameter="{Binding StationUri}">
									<Run Text="{Binding StationName}" />
								</Hyperlink>
							</Paragraph>
						</RichTextBox>

						<!--<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Stretch">
						<TextBlock TextWrapping="Wrap" FontSize="12" Margin="0 0 10 0"
							Text="{Binding ElapsedTimeText}"   />
						<TextBlock TextWrapping="Wrap" FontSize="12" 
							Text="{Binding StartDateTime, StringFormat=MM/dd(ddd) hh:mm}" />
					</StackPanel>-->
					</Grid>
				</Grid>
			</Border>
		</DataTemplate>

        <ItemsPanelTemplate x:Key="AlertItemsPanelTemplate">
            <StackPanel/>
        </ItemsPanelTemplate>
    </UserControl.Resources>

	<Grid x:Name="LayoutRoot">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition />
		</Grid.RowDefinitions>
		
		<!-- Search bar -->
		<Grid Grid.Row="1">
			<TextBox VerticalAlignment="Center" Margin="8" />
		</Grid>

		<!-- Body -->
		<ListBox Grid.Row="2" 
				 
				 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
				 ItemTemplate="{StaticResource AlertItemTemplate}" ItemsSource="{Binding AlertItems}" 
				 ItemContainerStyle="{StaticResource AlertItemContainerStyle}"
				 ItemsPanel="{StaticResource AlertItemsPanelTemplate}"
				  />
		
	</Grid>
</UserControl>
